package com.hjc.springbootmovies.mapper;

import com.hjc.springbootmovies.entity.ModelHall;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: HJC
 * Date: 2019/12/6
 * Time: 8:10
 * To change this template use File | Settings | File Templates.
 */
@Mapper
public interface  MappingHall {

    @Select("SELECT * FROM hall")
    List<ModelHall> queryHall();

    @Select("SELECT tid,tname,tcount FROM hall WHERE tid = #{tid}")
    ModelHall queryById(int tid);

    @Select("select * from hall where tid in (select tid from broad where fid = #{fid} )")
    List<ModelHall> queryByBroad(@Param("fid")int fid);

    @Insert("INSERT INTO hall(tname,tcount) VALUES(#{tname} ,#{tcount} )")
    @Options( useGeneratedKeys = true , keyColumn = "tid")
    int addHall(ModelHall modelHall);

    @Delete("DELETE FROM hall WHERE tid=#{tid} ")
    int deleteById(int tid);

    @Update("UPDATE hall SET tname = #{tname} ,tcount = #{tcount} WHERE tid=#{tid} ")
    int updateHall(ModelHall modelHall);
}
